package com.demo.redis.config;

import com.fasterxml.jackson.core.sym.Name1;
import com.test1.Test1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * 描述：
 * 作者 张超
 * 时间 2018/6/1
 * 项目 springboot-demo v2.0
 * 版本 v1.0
 */
@RestController
public class TestController {

    @Autowired
    private RedisTemplate<Object, Object> redisTemplate;

    @PostMapping
    public String save(@RequestBody User user) {

        Object o = redisTemplate.opsForValue().get(user.getName());
        if (o != null) {
            user.setCount(user.getCount() + 1);
        }
        redisTemplate.opsForValue().set(user.getName(), user);
        return "ok";
    }

    @GetMapping
    public Object get(@RequestParam String name) {
        Test1 test1 = new Test1();
        test1.getName1();
        Object o = redisTemplate.opsForValue().get(name);
        return o;
    }


}
